import { connect } from 'dva';
import React from 'react';
import Group from "../../components/group/group";

class groupRoute extends React.Component{
  render(){

    const { dispatch, group } = this.props;
    const { groupList } = group;

    const groupPros = {
      groupList,
      onEdit: (values) => {
        dispatch({
          type: 'group/updateOne',
          payload: values,
        });
      },

      onAdd: (values) => {
        dispatch({
          type: 'group/addOne',
          payload: values,

        });
      },

      onDelete: (values) => {
        dispatch({
          type: 'group/deleteOne',
          payload: values,
        });
      }
    };


    return (
      <div>
        <Group {...groupPros}/>
      </div>
    )
  }
}

function mapStateToProps(state) {
  return {
    group: state.group,
  };
}

export default connect(mapStateToProps)(groupRoute);
